package com.puzzlebazar.client.squaregrid.model;

import com.puzzlebazar.client.puzzle.model.Move;
import com.puzzlebazar.client.util.GridValidity;
import com.puzzlebazar.client.util.Vec2i;

public interface StateGrid extends ResizableGrid, GridValidity {
	
	/**
	 * Changes the state at the provided cell location
	 * The user should make sure to call notifyObservers( moveList ) after this move,
	 * passing along the generated move list,
 	 * or notifyObservers() to refresh the entire board.
	 * 
	 * @param loc Cell location to change the state at
	 * @param stateAfter The new state after the change
	 * @param time The time of the move
	 * @return The list of moves generated to affect that state change
	 * @throws exception
	 */
	public Move setState(Vec2i loc, int stateAfter, long time) throws Exception;

	
	/**
	 * Access the state at the provided cell location
	 * 
	 * @param loc Cell location to access the state at
	 * @return The current state at that location
	 * @throws Exception
	 */
	public int getState(Vec2i loc) throws Exception;
	
	
	/**
	 * Access to the number of different states in this model. All the states must be
	 * continuous starting from zero. State 0 is counted (hence, a model with state 0,1,2 should
	 * return 3 as the number of states)
	 * 
	 * @return The number of different states in this model
	 */
	public int getNbStates();

	/**
	 * Access the index of the defautlt state
	 * 
	 * @return The default state
	 */
	public int getDefaultState();

	/**
	 * Resets all the states in the grid to their default value
	 * The user should make sure to call notifyObservers() after this.
	 * 
	 * @param time The time of the move
	 */
	public Move clearStates( long time );



}
